package cn.stylefeng.guns.modular.question.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.User.param.UserOrgParam;
import cn.stylefeng.guns.modular.question.param.questionParam;
import cn.stylefeng.guns.modular.question.service.questionService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class QuestionController {

    @Resource
    private questionService questionService;


    @GetMapping("/question/list")
    @BusinessLog(title = "quenstion_org_增加_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(questionParam questionParam){
        return new SuccessResponseData(questionService.list(questionParam));
    }

    @PostMapping("/question/add")
    @BusinessLog(title = "quenstion_org_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(questionParam.add.class) questionParam questionParam) {
        questionService.add(questionParam);
        return new SuccessResponseData();
    }

    @PostMapping("/question/delete")
    @BusinessLog(title = "quenstion_org_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(questionParam.delete.class) questionParam questionParam) {
        questionService.delete(questionParam);
        return new SuccessResponseData();
    }

    @PostMapping("/question/edit")
    @BusinessLog(title = "quenstion_org_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(questionParam.edit.class) questionParam questionParam) {
        questionService.edit(questionParam);
        return new SuccessResponseData();
    }


    @PostMapping("/question/changeStatus")
    @BusinessLog(title = "user_org_修改状态", opType = LogAnnotionOpTypeEnum.CHANGE_STATUS)
    public ResponseData changeStatus(@RequestBody @Validated(questionParam.changeStatus.class) questionParam questionParam) {
        questionService.changeStatus(questionParam);
        return new SuccessResponseData();
    }

}
